﻿@using CNKI.TPI.Web.Base
@{
    ViewBag.Title = "论文提交登录";
}

<script type="text/javascript">
    function Login() {
        var loginForm = $('#LoginForm');
        loginForm.submit();
    }
</script>

<div class="panel panel-default" style="width:700px; text-align:center; margin:0 auto; margin-top:30px;">
    <div class="panel-body" >
        <div class="power-login">
            <h2 class="power-login-t" style="text-align:center;" ><span>【@ViewBag.dbName】提交登录</span></h2>
            @using (Html.BeginForm("SubmitLogin", "Submit", new { ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post, new { id = "LoginForm", @class = "form-horizontal" }))
            {
                @Html.AntiForgeryToken()
                <div id="dvErr" class="form-group" style="margin-top: 20px; font-size: 16px; color: red; text-align: center;">@Html.ValidationSummary(true)
                </div>
                    if (ViewBag.RegValue != null)
                    {
                        if (ViewBag.RegField != null)
                        {
                            string strFieldAlics = "";
                            string strFieldName = "";
                            string[] sArray = ViewBag.RegField.Split(',');
                            foreach (string s in sArray)
                            {
                                strFieldAlics = ColumnAliasHelper.GetAliasColumn(@ViewBag.dbCode, s);
                                if (String.IsNullOrEmpty(strFieldAlics))
                                {
                                    strFieldName = s.ToString();
                                }
                                else
                                {
                                    strFieldName = strFieldAlics;
                                }
                                
                                <div class="form-group" style="margin-top: 20px;">
                                <label class="col-sm-3 control-label">@strFieldName</label>
                                <div class="col-sm-5">
                                    @Html.TextBox(""+s+"", null, new { @class = "form-control", placeholder = "输入"+strFieldName+"", checktype = "required", requiredmessage = "*" ,maxlength = "50" })
                                </div>  
                                </div>
                            }
                        }
                    }    
                    else
                    {        
                        <div class="form-group" style="margin-top: 20px; display:block;">
                            <label for="pw1" class="col-xs-3 control-label">密码</label>
                            <div class="col-xs-5">
                               @Html.Password("Password", null,new { @class = "form-control", placeholder = "输入密码", checktype = "required", requiredmessage = "*" , maxlength="50" })
                            </div>
                        </div>
                    }
                <div class="form-group" style="margin-top: 10px;">
                    <div class="col-xs-3"></div>
                    <div class="col-xs-5" style="text-align:left;">
                        <button type="submit" id="btnLogin" class="btn btn-l btn-submit btn-warn-f">登录</button>
                    </div>
                </div>
                <input type="hidden" id="dbID" name="dbID" value="@ViewBag.dbID" />
                <input type="hidden" id="dbCode" name="dbCode" value="@ViewBag.dbCode" />
                <input type="hidden" id="displayDBName" name="displayDBName" value="@ViewBag.dbName" />
                <input type="hidden" id="RegValue" name="RegValue" value="@ViewBag.RegValue" />
                <input type="hidden" id="RegField" name="RegField" value="@ViewBag.RegField" />
            }
        </div>
    </div>
</div>
<script type="text/javascript">
    $(function () {
        $('#LoginForm').validation();
        $("#btnLogin").on('click', function (event) {
            if ($("#LoginForm").valid() == false) {
                return false;
            }
            else {
                $("#LoginForm").submit();
                return false;
            }
        })
    })
</script>

